package com.guguskins.back.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guguskins.back.entity.GuSlide;
import com.guguskins.back.entity.vo.ResultVo;
import com.guguskins.back.service.GuSlideService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 幻灯片（轮播图） 前端控制器
 * </p>
 *
 * @author mybatis-plus
 * @since 2021-05-17
 */
@RestController
@RequestMapping("/slide")
public class GuSlideController {

    @Autowired
    private GuSlideService slideService;

    @GetMapping("/list/{type}")
    public ResultVo listByType(@PathVariable Integer type) {
        List<GuSlide> slides = slideService.list(new LambdaQueryWrapper<GuSlide>() {
            {
                eq(GuSlide::getSlideType, type);
                orderByAsc(GuSlide::getSlideSort);
            }
        });
        return ResultVo.success(slides);
    }

}
